<template>
  <div id="app">
    <!-- 头部 -->
    <header>
      <span></span><input type="text">
    </header>
    <!-- 选项卡按钮 -->
    <!-- :list="list"是父子传参 -->
    <main>
      <TabTitle :list="list" :activeIndex="activeIndex"></TabTitle>
    <!-- 选项卡内容 -->
    <!-- activeIndex 默认渲染下标为0 的数据 -->
    <Tabbody :children="list[activeIndex].children"/>
    </main>
    
  </div>
</template>

<script>
import TabTitle from "./components/TabTitle";
import Tabbody from "./components/Tabbody";
import Mock from "mockjs";
const data=Mock.mock({
  "list|15":[{
    title:"@ctitle(2)",
    "children|10-15":[
      {
        img:"@image(100x100,@color)",
        name:"@name",
       
      }
    ]
  }]
})

export default {
  name: 'App',
  components: {
    TabTitle,
    Tabbody,
  },
  data(){
    return{
      list:data.list,
      activeIndex:0
    };
  },
  // mounted是一个生命周期，dom结构挂载完毕的生命周期（房子盖好了）
  mounted(){
    console.log(11111,this.bus);
    // thi.bus.$on是给父亲身上安装电话
    // 参数一：定义一个电话号码

    // this.bus可以实现子父传参
    this.bus.$on("changeActive",(index)=>{
      console.log("等儿子给我打电话",index);
      this.activeIndex=index;
    })
  }
}
</script>

<style>
*{
  margin: 0;
  padding: 0;
  list-style: none;
  box-sizing: border-box;
}
html,body,#app{
  width: 100%;
  height: 100%;
}
header{
  width: 100%;
  height: 60px;
}
main{
 width: 100%;
 height: calc(100% - 60px);
 overflow: auto;
}
.le{
  width: 80px;
  height: 100%;
  background: #fcc;
  float: left;
}
.le ul {
  width: 100%;
  height: 100%;
}
.le ul li{
  width: 100%;
  height: 45px;
  text-align: center;
  line-height: 45px;
}
.rt{
  width: calc(100% - 80px);
  height: auto;
  float: left;
  display: flex;
  flex-wrap: wrap;
}
</style>
